package splitgroup;

import java.io.BufferedReader;
import java.util.LinkedList;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Eagle
 */
public class spliterClass {
    private class oldClass{
        int ID1,ID2,ID3,ID4,size;
        void setSize(int ss){
            size=ss;
        }
        
        oldClass(int id1, int id2, int id3){
            size=3;
            ID1=id1;
            ID2=id2;
            ID3=id3;
        }
        
        oldClass(int id1, int id2, int id3, int id4){
            size=4;
            ID1=id1;
            ID2=id2;
            ID3=id3;
            ID4=id4;
        }
    }
    
    private class newClass{
        int ID1, ID2, ID3, GID;
    }

    LinkedList<oldClass> ll=new LinkedList<oldClass>();


    spliterClass(BufferedReader br) {

          String s;
          int[][] ar=new int[1000][2];
          int arcount=0;

          int gs, id;
              //Read File Line By Line
          try{
              while ((s = br.readLine()) != null)   {
                  gs=Integer.parseInt(s.substring(0,1));
                  if (s.substring(4,5).equals(",")){
                      id=Integer.parseInt( s.substring(2,4));
                  }else{
                       id=Integer.parseInt( s.substring(2,5));
                  }
                  ar[arcount][0]=gs;
                  ar[arcount][1]=id;
                  arcount++;
                                    //Close the input stream
                  
              }
               br.close();
          }catch (Exception e){//Catch exception if any
              System.err.println("Error: " + e.getMessage());

          }
          int GID=0;
          int ct2=0;
          int sz2;
          while(ct2<arcount-2){
              sz2=ar[ct2][0];
              if(sz2==3){
                  for (int ct3=0;ct3<sz2;ct3++){
                      String s1=GID+","+ar[ct2][1];
                      dp(s1);
                      ct2++;
                  }
                  GID++;
              }
               else{
                    String s1=GID+","+ar[ct2][1];
                    String s2=GID+","+ar[ct2+1][1];
                    String s3=GID+","+ar[ct2+2][1];
                    GID++;
                    String s4=GID+","+ar[ct2][1];
                    String s5=GID+","+ar[ct2+1][1];
                    String s6=GID+","+ar[ct2+3][1];
                    GID++;
                    String s7=GID+","+ar[ct2][1];
                    String s8=GID+","+ar[ct2+2][1];
                    String s9=GID+","+ar[ct2+3][1];
                    GID++;
                    String s10=GID+","+ar[ct2+1][1];
                    String s11=GID+","+ar[ct2+2][1];
                    String s12=GID+","+ar[ct2+3][1];
                    GID++;
                    ct2+=4;
                    dp(s1);
                    dp(s2);
                    dp(s3);
                    dp(s4);
                    dp(s5);
                    dp(s6);
                    dp(s7);
                    dp(s8);
                    dp(s9);
                    dp(s10);
                    dp(s11);
                    dp(s12);

               }

        }


    }
    void dp(String s){
        System.out.println(s);
    }
    void dp(int s){
        System.out.print(s);
    }

}
